function missingNumber1(nums: number[]): number {
    for (let i = 0; i < nums.length; i++){
        if (i !== nums[i]) {
            return i;
        }
    }
    return nums.length;
};

// 二分查找
function missingNumber(nums: number[]): number {
    let i = 0, j = nums.length - 1;
    while (i <= j) {
        let m = Math.floor((i + j) / 2)
        if (nums[m] === m) {
            i = m + 1;
        } else {
            j = m - 1;
        }
    }
    return i;
};